package com.example.service;

import java.util.List;
import java.util.Map;

import com.example.dto.ApiResponse;
import com.example.dto.ExamRequest;
import com.example.entity.Exam;
import com.example.entity.ExamRecord;
import com.example.dto.MarkingSubmissionDTO;
import com.example.dto.ExamStatisticsDTO;

public interface ExamService {
    
    // 考试基本操作
    List<Exam> getAllExams();
    List<Exam> getTeacherExams(Long teacherId);
    List<Exam> getClassExams(Long classId);
    List<Exam> getStudentExams(Long studentId);
    Exam getExamById(Long id);
    
    // 考试创建和管理
    ApiResponse<?> createExam(ExamRequest examRequest, Long teacherId);
    ApiResponse<?> updateExam(Long id, ExamRequest examRequest, Long teacherId);
    ApiResponse<?> deleteExam(Long id, Long teacherId);
    ApiResponse<?> saveDraft(Long id, ExamRequest examRequest, Long teacherId);
    
    // 考试班级分配管理
    ApiResponse<?> assignExamToClass(Long examId, Long classId, Long teacherId);
    ApiResponse<?> removeExamFromClass(Long examId, Long classId, Long teacherId);
    
    // 考试状态管理
    ApiResponse<?> publishExam(Long id, Long teacherId);
    ApiResponse<?> startExam(Long examId, Long teacherId);
    ApiResponse<?> endExam(Long examId, Long teacherId);
    ExamRecord startExam(Long examId, Long studentId, Long classId);
    
    // 题目管理
    ApiResponse<?> addQuestions(Long examId, List<Long> questionIds, Long teacherId);
    ApiResponse<?> removeQuestions(Long examId, List<Long> questionIds, Long teacherId);
    ApiResponse<?> generateRandomQuestions(Long examId, ExamRequest request, Long teacherId);
    
    // 考试进行
    ApiResponse<?> startExamByStudent(Long examId, Long studentId, Long classId);
    ApiResponse<?> submitExam(Long examId, Long studentId, String answers);
    ApiResponse<?> recordSuspiciousAction(Long examId, Long studentId, String actionType, String details);
    ApiResponse<?> saveQuestionAnswer(Long examId, Long questionId, Long studentId, String answer);
    
    // 新增：获取考试剩余时间
    ApiResponse<?> getRemainingTime(Long examId, Long studentId);
    
    // 考试记录和批改
    List<ExamRecord> getExamRecords(Long examId);
    ExamRecord getStudentExamRecord(Long examId, Long studentId);
    ApiResponse<?> startMarking(Long recordId, Long teacherId);
    ApiResponse<?> submitMarking(Long recordId, MarkingSubmissionDTO submission, Long teacherId);
    
    // 统计和分析
    ExamStatisticsDTO getExamStatistics(Long examId);
    Map<String, Object> getStudentExamHistory(Long studentId);
    Map<String, Object> getClassExamStatistics(Long examId, Long classId);
    
    // 作弊检测
    List<Map<String, Object>> getSuspiciousActions(Long examId);
    List<Map<String, Object>> getStudentSuspiciousActions(Long examId, Long studentId);

    // 学生考试记录查询
    ApiResponse<?> getStudentExamRecordDetail(Long examId, Long studentId);
    ApiResponse<?> getStudentExamRecordList(Long studentId);
} 